package dao;

import com.javaweb.config.SpringConfig;
import com.javaweb.dao.ArticleDao;
import com.javaweb.dao.CommentDao;
import com.javaweb.model.Article;
import com.javaweb.model.Comment;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={SpringConfig.class})
public class CommentDAotest {
    @Autowired
    private CommentDao commentDao;
    @Test
    public void insertComment(){
        Comment comment = new Comment().setUserId(1)
                .setContent("我的文章").setArticleId(2).setCreateTime(new Date()).setUpdateTime(new Date()).setOppose(4).setSupport(6).setUserId(3);

        int ret = commentDao.insert(comment); ;
        Assert.assertTrue(ret > 0);

    }
    @Test
    public void testInsertSupport() {
      commentDao.insertSupport(1);

    }

    //点差
    @Test
    public void testInsertOppose() {
        commentDao.insertOppose(1);
    }

    //查询文章对应的所有评论
    @Test
    public void testSelectAllCommentsById() {
        System.out.println(commentDao.selectAllCommentsById(1));
    }

}
